import { defineStore } from "pinia";

//定义store
export const useCityStore = defineStore('city',{
    //状态，存储当前城市位置信息
    state:()=>{
        return{
            location:{
                  "name":"北京",
                  "id":"101010100",
                  "lat":"39.90499",
                  "lon":"116.40529",
                  "adm2":"北京",
                  "adm1":"北京市",
                  "country":"中国",
                  "tz":"Asia/Shanghai",
                  "utcOffset":"+08:00",
                  "isDst":"0",
                  "type":"city",
                  "rank":"10",
                  "fxLink":"https://www.qweather.com/weather/beijing-101010100.html"
            }
        }
    },
    //同步修改状态的方法
    actions:{
        updateLocation(location){
            this.location = location//直接修改城市位置状态
        }
    },
    getters:{
        getLocation(){
            return this.location
        }
    }

    
})